function [sequences repetitions] = removeRepetition(sequences)

if ~iscell(sequences)
    [sequences repetitions] = removeRepetitionsFromSequence(sequences);
else
    repetitions = cell(size(sequences));
    for i = 1:size(sequences, 1)
        for j = 1:size(sequences, 2)
            [temp_seq temp_rep] = removeRepetitionsFromSequence(sequences{i, j});
            sequences{i, j} = temp_seq;
            repetitions{i, j} = temp_rep;
        end
    end
end



function [sequence repetitions] = removeRepetitionsFromSequence(sequence)

k = 2;
repetitions = [1];
while k <= length(sequence)
    if sequence(k) == sequence(k-1);
        sequence(k) = [];
        repetitions(k-1) = repetitions(k-1)+1;
    else
        k = k + 1;
        repetitions = [repetitions 1];
    end
end
